#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h>
#include<stdbool.h>

int count = 1;
void COUNT(int y)
{
	
	if (y > 9)
	{
		COUNT(y / 10);
		count++;
	}
}

_Bool Lily_num_orl(int x)
{
	int i = 0;
	int n = 10000;
	int arr[5] = { 0 };
	COUNT(x);
	int j = 0;
	int sum = 0;

	for (i = 0; i < 5; i++)
	{
		arr[i] = (x / n) % 10;
		n = n / 10;
	}

	for (j = 0; j < 5; j++)
	{
		sum = sum + pow(arr[j], count);
	}

	if (sum == x)
	{
		return true;
	}
	else
		return false;
}

int main()
{
	int num = 0;

	for (num = 0; num <= 100000; num++)
	{
		if (Lily_num_orl(num))
		{
			printf("%d ", num);
		}
		count = 1;
	}

	return 0;
}